home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 273_01.zip / SAVESCR.CA < prev    next >
Text File  |  1993-04-04  |  2KB  |  75 lines

  1. #include <dos.h>
  2.  
  3. save_scr(int trow, int tcol, int brow, int bcol, char *array)
  4. /* Save an area of the current screen into a character array
  5.    To determine num of chars for array use the following formula:
  6.    num_chars=((brow-trow+1) * (bcol-tcol+1)) *2;
  7. */
  8. {
  9. extern bios, mono, cga;
  10. int x, y, orow, ocol, ncols, scrofs;
  11. union REGS inregs;
  12. char pchar;
  13. char far *base;
  14. char far *work;
  15.  
  16.     if(mono) base = (char far *) 0xb0000000;
  17.     else     base = (char far *) 0xb8000000;
  18.  
  19.     ncols = bcol - tcol + 1;
  20.     if(bios) {
  21.         get_cur(&orow,&ocol);
  22.         for(x=trow; x<=brow; x++) {
  23.             for(y=tcol; y<=bcol; y++) {
  24.                 locate(x,y);
  25.                 inregs.h.ah = 0x08;
  26.                 inregs.h.bh = 0x00;
  27.                 int86(0x10,&inregs,&inregs);
  28.                 *array++ = inregs.h.al;
  29.                 *array++ = inregs.h.ah;
  30.             }
  31.         }
  32.         locate(orow,ocol);
  33.         return(0);
  34.     }
  35.  
  36.     for(x=trow;x<=brow;x++) {
  37.         scrofs = ((((x + 1) * 160) - 160) + ((tcol + 1) * 2)) - 2;
  38.         work = base + scrofs;
  39.         for(y=0; y<ncols ;y++) {
  40.             asm les     bx,work
  41.             if(cga) {
  42.                 asm mov     dx,03dah
  43.                 asm in      al,dx
  44.                 asm test    al,1
  45.                 asm jnz     $-3
  46.                 asm in      al,dx
  47.                 asm test    al,1
  48.                 asm jz      $-3
  49.             }
  50.             asm mov     cl,byte ptr es:[bx]
  51.             asm mov     pchar,cl
  52.             *array = pchar;
  53.             work++; array++;
  54.             asm les     bx,work
  55.             if(cga) {
  56.                 asm mov     dx,03dah
  57.                 asm in      al,dx
  58.                 asm test    al,1
  59.                 asm jnz     $-3
  60.                 asm in      al,dx
  61.                 asm test    al,1
  62.                 asm jz      $-3
  63.             }
  64.             asm mov     cl,byte ptr es:[bx]
  65.             asm mov     pchar,cl
  66.             *array = pchar;
  67.             work++; array++;
  68.         }
  69.     }
  70.  
  71. }
  72.  
  73.  
  74.     
  75.